#!/usr/bin/env bash
pid=$(jps | grep inspect-line-2.0.jar | awk '{print $1}')
# 服务部署路径
# shellcheck disable=SC2154
baseDir=$(pwd)
[[ -n ${pid} ]] && kill -9 "${pid}"
# shellcheck disable=SC2174
[[ ! -e "${baseDir}"/history-log/ ]] && mkdir -m 755 -p "${baseDir}"/history-log
# shellcheck disable=SC2174
[[ ! -e "${baseDir}"/history-jar/ ]] && mkdir -m 755 -p "${baseDir}"/history-jar
# shellcheck disable=SC2046
[[ -e "${baseDir}"/inspect-line-2.0.log ]] && cp "${baseDir}"/inspect-line-2.0.log "${baseDir}"/history-log/inspect-line-2.0-$(date +%Y-%m-%d_%H:%M:%S).log
# shellcheck disable=SC2046
[[ -e "${baseDir}"/inspect-line-2.0.jar ]] && cp "${baseDir}"/inspect-line-2.0.jar "${baseDir}"/history-jar/inspect-line-2.0-$(date +%Y-%m-%d_%H:%M:%S).jar
export MALLOC_ARENA_MAX=1
nohup java -jar -server -Xms2048m -Xmx2048m -Xmn1024m -Xss512k -Dsun.zip.disableMemoryMapping=true "${baseDir}"/inspect-line-2.0.jar --spring.profiles.active=prod >"${baseDir}"/inspect-line-2.0.log 2>&1 &
echo "Process $! start Success!"
tailf "${baseDir}"/inspect-line-2.0.log
